package com.huike.web.controller.report;

import com.huike.common.utils.SecurityUtils;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.IReportService;

import java.util.concurrent.ExecutionException;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;


    /**
     * 首页--基础数据统计
     *
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime) {
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime, endCreateTime));
    }


    //今日简报
    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo() throws ExecutionException, InterruptedException {
        return new AjaxResult(200, "操作成功", reportService.getAllNum(SecurityUtils.getUsername()));
    }

    //待办事项
    @GetMapping("/getTodoInfo")
    public AjaxResult getTodoInfo(@RequestParam String beginCreateTime, @RequestParam String endCreateTime) {

        return new AjaxResult(200, "操作成功", reportService.getAllNum(SecurityUtils.getUsername(), beginCreateTime, endCreateTime));

    }

    //商机转合同龙虎榜
    @GetMapping("/businessChangeStatistics")
    public AjaxResult getBusinessChangeStatistics(@RequestParam String beginCreateTime, @RequestParam String endCreateTime) {

        return new AjaxResult(200, "操作成功", reportService.getBusinessChangeStatistics(beginCreateTime, endCreateTime));
    }

    //线索转化龙虎榜
    @GetMapping("/salesStatistic")
    public AjaxResult getSalesStatistic(@RequestParam String beginCreateTime, @RequestParam String endCreateTime) {

        return new AjaxResult(200, "操作成功", reportService.getSalesStatistic(beginCreateTime, endCreateTime));
    }
}